<script>window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')</script>
	<!-- Anything Slider -->
<script src="js/jquery.anythingslider.js"></script>
	<!-- AnythingSlider initialization -->
<?php

//RECUPERATION ET TRANSFORMATION DES LIGNES-----------
$reqLigne=mysql_query("SELECT * FROM actualites WHERE MiseEnLigneActu='oui' AND Annee='$Year' ORDER BY Annee , Mois, Jour ") or die(mysql_error());
$nbLigne=mysql_num_rows($reqLigne);
if($nbLigne>0){
	$ni=0;
	$tabDate = "[";
	$Lignes="return[";
	//$Lignes.="'', ";
	while($row=mysql_fetch_array($reqLigne)){

		if($ni > 0){
			$tabDate .= ",";
		}
		$tabDate .= "'".$row['Jour'] ."-". $row['Mois'] ."-". $row['Annee']."'";
		
		$Jour=$row['Jour'];
		$Mois=str_replace($NumMois, $LetterMois, $row['Mois']);
		$NomJour=$row['NomJour'];
		$ni++;
		$Lignes.="'".$NomJour." ".$Jour." ".$Mois;
		if($ni<$nbLigne){
			$Lignes.="', ";
		}else{
			$Lignes.="'";
		}
	}
	$tabDate .= "]";
	$Lignes.="][index - 1];";
}
echo "<script>
		var tabDate = ".$tabDate.";
		var positionToDisplay = 0;
		var smallBetweenTime = 0;
		var tabDateTime = [];
		var betweenTime = 0;
		for(i=0;i<tabDate.length;i++){
			aDateTab = tabDate[i].split('-');
			var d = new Date(aDateTab[2], aDateTab[1] - 1 , aDateTab[0], 23, 59, 59, 0);
			tabDateTime[i] = d;
		}
		var today = new Date();
		for(j=0;j<tabDateTime.length;j++){
			if(today <= tabDateTime[j]){
				betweenTime = tabDateTime[j].getTime() - today.getTime();
				if(smallBetweenTime == 0){
					smallBetweenTime = betweenTime;
					positionToDisplay = j + 1 ;
				}else{
					if(betweenTime < smallBetweenTime){
						smallBetweenTime = betweenTime;
						positionToDisplay = j + 1;
					}  
				}
			}
		}
		
		// DOM Ready
		$(function () {
				
			if(positionToDisplay == 0){
		    	positionToDisplay = $('#slider div.Contain').size();
			}		    
			$('#slider').anythingSlider({
			
				autoPlay            : false,
				 startPanel          : positionToDisplay,
				   onInitialized       : $('.anythingControls .next').click(),

				navigationFormatter : function(index, panel){
				".$Lignes."
				}
			});
		});
</script>";
?>
<script>
$("#slide-jump").click(function(){
				$('#slider').anythingSlider(4);
				return false;
			});
			</script>